package com.example.demo01.entity;

import androidx.exifinterface.media.ExifInterface;
import lombok.Data;

import java.io.IOException;
import java.io.InputStream;

/**
 * <p>
 *
 * </p>
 *
 * @author DONG.WANG17@HAND-CHINA.COM
 * @since 2024-11-07 20:03
 */
@Data
public class ExifInfo {
    private String artist;
    private String make;
    private String model;
    private String lensModel;
    private int orientation;
    public ExifInfo(InputStream imageInputStream) throws IOException {
        ExifInterface exif = new ExifInterface(imageInputStream);
        this.artist =this.withDefault(exif.getAttribute(ExifInterface.TAG_ARTIST),"xz") ;
        this.make = this.withDefault(exif.getAttribute(ExifInterface.TAG_MAKE),"LUMIX");
        this.model = this.withDefault(exif.getAttribute(ExifInterface.TAG_MODEL),"DC-S5M2");
        this.lensModel = this.withDefault(exif.getAttribute(ExifInterface.TAG_LENS_MODEL),"LUMIX");
        this.orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
    }
    private String withDefault(String value, String defaultValue) {
        return value == null ? defaultValue : value.trim();
    }
}
